/*
这题暴力最多60分
强连通分量啥的，能力上来了再说吧
*/

#include <bits/stdc++.h>

#define N 100005

using namespace std;

/*struct edge{
    int to;
    int val;
};*/

vector <int> G[N];
int ans[N] = {0};
int vis[N] = {0};

void dfs(int fr, int to){
    if(vis[to]) return;
    vis[to] = 1;
    bool find = false;  //是否找到更大的
    for(int i = 0; i < G[to].size(); i++){
            dfs(fr, G[to][i]);
    }
    if(!find){
        ans[fr] = max(ans[fr], to);
        return;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
    }
    for(int i = 1; i <= n; i++){
        memset(vis, 0, sizeof(vis));
        dfs(i, i);
    }
    for(int i = 1; i <= n; i++){
        printf("%d ", ans[i]);
    }
    return 0;
}